Deploying Kanzi applications to Android
Before you can build and deploy Kanzi applications for Android, you need to set up the Kanzi build environment for Android and install on your computer the USB device drivers for your Android device. See Installing Kanzi build environment for Android.
Building and deploying Kanzi applications from Kanzi Studio
To build and deploy your Kanzi application to Android from Kanzi Studio:
- Connect your Android device to your computer.
- In Kanzi Studio open your Kanzi project and select > Build Android Package.
Kanzi Studio builds the application source code, creates APK package, and installs the package to your Android device.
Building Kanzi applications with SCons
To build your Kanzi application with Scons use the scons command:
scons <ES1|GL21> <debug|release|profile> <ProjectName>
Run the SCons build command in the configuration directory of the platform for which you want to build the Kanzi application. For example, to build your Kanzi application for Android, run the SCons build command in the <ProjectName>/Application/configs/platforms/android directory.
SConstruct file contains information about Kanzi Engine location and runs the following config files:
- Engine/configs/platforms/common/config.py includes Kanzi library definitions and common build flags.
- Engine/configs/platforms/<PlatformName>/config.py includes Kanzi platform-specific build flags and defines, and toolchain.
- <ProjectName>/Application/configs/platforms/common/config.py includes optional project specific common configuration parameters.
- <ProjectName>/Application/configs/platforms/<PlatformName>/config.py includes optional project specific platform configuration parameters.
Project configuration parameters include:
- binary_name is the name of the compiled native binary, same as project name if not specified
- depends are dependencies from libraries or other source modules, Kanzi libraries if not specified. Default are System, Core, User, and ApplicationFramework.
Building and deploying Kanzi applications for Android with SCons
To build and deploy your Kanzi application to Android using SCons:
- Connect your Android device to your computer.
- Launch the Windows command line and go to the Application/configs/platforms/android
directory of your project.
For example, if your project is called MyProject, go to the MyProject/Application/configs/platforms/android directory.
- Build your Kanzi application with Scons by running
scons es2 debug <KanziProjectName>.
Scons builds the application source code and creates the APK package in the Application/output directory.
For example, if your project is called MyProject, run the following command:
scons es2 debug MyProject
Scons creates the APK package with the same name as the project name in the MyProject/Application/output directory.
- Install the application on your Android device by running
adb install in the Application/output directory.
ADB installs the package to your Android device.
For example, if your project is called MyProject and is stored in the KanziWorkspace, run the following command:
adb install C:\KanziWorkspace\Projects\MyProject\Application\output\MyProject-debug.apk
Troubleshooting
- When deploying a Kanzi application to an Android device with a locked screen, running the application can fail or present wrong visual result. To get the correct result, restart the application.
-
When you receive the following error message while compiling Kanzi applications for Android:
[dex] Pre-Dexing C:\KanziWorkspace\3rdPartySDKs\android-sdk-windows\tools\support
\annotations.jar -> annotations-fa751cd593bf7078e9c18d47a485e852.jar
[dx] Error: Could not create the Java Virtual Machine.Error occurred during
initialization of VM
[dx] Error: A fatal exception has occurred. Program will exit.
[dx]
[dx] Could not reserve enough space for object heap
BUILD FAILED
Limit the max heap size of the dx tool in <KanziWorkspace>/3rdPartySDKs/android-sdk-windows/build-tools/18.1.0/dx.bat. Change the line:
set defaultXmx=-Xmx1024M
to
set defaultXmx=-Xmx512M
See also
Installing Kanzi build environment for Android
Creating your first application
Android OEM USB Drivers
Open topic with navigation